//
//  StartView.m
//  项目1 CLCMovie
//
//  Created by huiwenjiaoyu on 15/7/21.
//  Copyright (c) 2015年 CLC. All rights reserved.
//

#import "StartView.h"

@implementation StartView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if (self) {
        [self creatStart];
        
    }
    
    return self;
}

- (void)awakeFromNib
{
    [self creatStart];

}

- (void)creatStart
{
    UIImage* img1 = [UIImage imageNamed:@"gray"];
    UIImage* img2 = [UIImage imageNamed:@"yellow"];
    
    float scale = self.frame.size.height/img1.size.height;
    
    _grayStart.transform = CGAffineTransformMakeScale(scale, scale);
    _yellowStart.transform = CGAffineTransformMakeScale(scale, scale);

    _grayStart = [[UIView alloc] initWithFrame:CGRectMake(0, 0, img1.size.width*5,img1.size.height)];
    _yellowStart = [[UIView alloc] initWithFrame:CGRectMake(0, 0, img2.size.width*5, img2.size.height)];
    
    _grayStart.backgroundColor = [UIColor colorWithPatternImage:img1];
    _yellowStart.backgroundColor = [UIColor colorWithPatternImage:img2];
        
    CGRect rect = _grayStart.frame;
    rect.origin = CGPointZero;
    _grayStart.frame = rect;
    
    rect = _yellowStart.frame;
    rect.origin = CGPointZero;
    _yellowStart.frame = rect;
    
    [self addSubview:_grayStart];
    [self addSubview:_yellowStart];

}

- (void)setMark:(float)mark
{
    _mark = mark;
    [self setNeedsLayout];
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    float flt = _mark/10;
    
    CGRect rect = _grayStart.frame;
    rect.size.width = rect.size.width*flt;
    
    _yellowStart.frame = rect;
    
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
